<?php
namespace app\index\controller;

use app\common\controller\Base;
use app\common\model\Apply;
use app\common\model\User;
use app\common\model\RecordBrokerage;
use think\Loader;

class Htmltoimg extends Base
{
    public function index()
    {
        $userId = $this->request->param('user_id');
        $applyId = $this->request->param('apply_id');
        $user = User::get($userId);
        $apply = Apply::get($applyId);

        $brokerage = RecordBrokerage::get(['user_id' => $userId, 'apply_id' => $applyId]);
        $this->assign('brokerage', $brokerage);
        $this->assign('user', $user);
        $this->assign('apply', $apply);
        return $this->fetch();
    }

    public function showQrcode() {
        $applyId = $this->request->param('apply_id');
        $apply = Apply::get($applyId);
        $url = url('/index/index/detail', ['activity_id' => $apply->aid, 'apply_id' => $applyId]);
        Loader::import('phpqrcode.phpqrcode', VENDOR_PATH, '.php');
        \QRcode::png($url, false, 'L', 5, 2);
    }
}
